const BASE_URL = 'https://api-hmugo-web.itheima.net';
// $http.baseUrl = 'https://api-hmugo-web.itheima.net';
import { $http } from '@escook/request-miniprogram'
/**
 * promise包装请求方法
 * @param {string} [url=''] 请求地址
 * @param {*} [data={}] 请求入参
 * @returns
 */
export default function({
	url = '',
	data = {},
	type = 'post',
	opts = { autoPrepenPath: false },
} = {}) {
	return new Promise((resolve, reject) => {
		uni.request({
			url: BASE_URL + '/' + url,
			data,
			type,
			success(res) {
				resolve(res);
			},
			error(err) {
				reject(err);
			},
		},
		opts
		);
	});
}